package com.bio.test2;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端，直接new Thread的方式
 * @author gxkj-042
 *
 */
public class Service {
	
	final static int port = 8765;
	
	public static void main(String[] args) {
		ServerSocket server = null;
		try {
			server = new ServerSocket(port);
			System.out.println("服务已经启动....");
			Socket socket = null;
			HandlerExecutorPool executorPool = new HandlerExecutorPool(50,1000);
			while (true) {
				//阻塞服务
				socket = server.accept();
				//新建一个线程执行,提交到线程池
				executorPool.execute(new ServerHandler(socket));
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
